#include "pch.h"
#include "RepeatObject.h"

using namespace D2D1;
RepeatObject::RepeatObject(void):
	m_xOffset(0),
	m_yOffset(0)
{
}


RepeatObject::~RepeatObject(void)
{
}

void RepeatObject::Update()
{
	Y=-20;
	m_xOffset+=RollXSpeed;
	m_yOffset+=RollYSpeed;
	if(m_xOffset>Width)
		m_xOffset=0;
	if(m_yOffset>100)
		m_yOffset=0;
}

void RepeatObject::Render(DisplayContext &dislpayEngine)
{
	if(targetImageFile==nullptr)
		return;
	if(!m_isImageLoaded)
		return;
	if(renderImage==NULL)
		return;
	Matrix3x2F transform = Matrix3x2F::Translation(RenderTransform.TranslateX,RenderTransform.TranslateY);
	dislpayEngine.D2DContext->SetTransform(transform);
	int num=Height/100;
	for(int i=0;i<num;++i)
	{
		dislpayEngine.D2DContext->DrawBitmap(renderImage.Get(),&RectF(X,Y-m_yOffset+i*100,Width+X,100+Y-m_yOffset+i*100));
	}



	//dislpayEngine.D2DContext->DrawBitmap(renderImage,RectF(X,Height-m_yOffset+Y,Width+X,2*Height-m_yOffset+Y));
}
